#include <bits/stdc++.h>
using namespace std;
const int N=105;
int n,m;
struct node{
    int a,b;

    bool operator <(const node& rhs)const{
        if(a==rhs.a){
            return b<rhs.b;
        }else{
            return a<rhs.a;
        }
    }
}c[N];
int main(void){
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&c[i].a,&c[i].b);
    }
    sort(c,c+m);
    int ans=0;
    int aa=c[0].a;
    int bb=c[0].b;
    for(int i=1;i<m;i++){
        if(c[i].a>bb){
            ans+=(bb-aa+1);
            aa=c[i].a;
            bb=c[i].b;
        }else{
            bb=max(bb,c[i].b);
        }
        //printf("%d %d\n",aa,bb);
    }
    //printf("%d %d\n",aa,bb);
    ans+=(bb-aa+1);
    printf("%d\n",n+1-ans);
    return 0;
}